//
//  PASetHomeViewController.m
//  PAMobileWallet
//
//  Created by Pay_SMP002 on 13-7-4.
//  Copyright (c) 2013年 平安付. All rights reserved.
//

#import "PASetHomeViewController.h"
#import "PublicDefine.h"
#import "PASetHomeView.h"
#import "PAFeedbackViewController.h"
#import "PAAboutViewController.h"
#import "PALoginViewController.h"
@interface PASetHomeViewController ()

@end

@implementation PASetHomeViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self){
        self.title = @"设置";

        setHomeView = [[PASetHomeView alloc] initWithFrame:RECT_PHONE];
        setHomeView.parentController = self;
        setHomeView.backgroundColor = BGVIEW_COLOR;
        self.view = setHomeView;
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
}

- (void)sendMessage:(NSInteger)sender
{
    PABaseViewController * baseViewController = nil;
    if (sender == 2){
        if (!feedbackViewController){
            feedbackViewController = [[PAFeedbackViewController alloc] initWithNibName:nil bundle:nil];
            feedbackViewController.parentController = self;
        }
        
        baseViewController = feedbackViewController;
    }
    else if (sender == 3){
        if (!aboutViewController){
            aboutViewController = [[PAAboutViewController alloc] initWithNibName:nil bundle:nil];
            aboutViewController.parentController = self;
        }
        
        baseViewController = aboutViewController;
    }
    else if (sender == 5){
        [self dismissModalViewControllerAnimated:NO];
        [[NSNotificationCenter defaultCenter] postNotificationName:NOT_NeedRelogin object:@{@"isNeedHome": [NSNumber numberWithBool:YES]}];
    }

    if (sender != 5){
        /*
        if (!navigationControllerT) {
            navigationControllerT = [self newNavigationControllerOfClass:@"PASetHomeViewController"];
        }
        [self.view addSubview:navigationControllerT.view];
        [navigationControllerT pushViewController:baseViewController animated:YES];
         */
        
        [self.view addSubview:baseViewController.view];
    }
}

//get new viewController with navigation bar
- (UINavigationController *)newNavigationControllerOfClass:(NSString *)classString
{
	Class ViewController =  NSClassFromString(classString);
	UIViewController *theViewController;
	theViewController = [[ViewController alloc] initWithNibName:classString bundle:nil];
	
	//create the navigation controller with the view controller
	UINavigationController *theNavigationController;
	theNavigationController = [[UINavigationController alloc] initWithRootViewController:theViewController];
	
	return theNavigationController;
}

- (void)gotoPersonalController:(id)sender
{
    [self dismissModalViewControllerAnimated:YES];
}

- (void)viewWillAppear:(BOOL)animated
{
    [self.navigationController.navigationBar setHidden:YES];
    NSString *userTFString = [PADataCenter sharedInstance].selfInfo.baseInfo.phoneNum;
    if (nil ==userTFString) userTFString = @"";
    [setHomeView.listArray replaceObjectAtIndex:0 withObject:userTFString];
    [setHomeView.setTableView reloadData];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

@end
